home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / CMPRSS.ZIP;1 / COMPRESS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-05  |  9.2 KB  |  187 lines

  1. /****************************************************************************
  2.  * COMPRESS.H
  3.  *
  4.  *      This header file contains the function and constant declarations for
  5.  *      the data compression functions in the COMPRESS.DLL dynamic link
  6.  *      library.
  7.  *
  8.  *      Modifications : 05-Mar-94 : Initial version.
  9.  ****************************************************************************/
  10.  
  11. #if !defined(OS2DEF_INCLUDED)
  12. #error The header file OS2.H must be included before this header file.
  13. #endif
  14.  
  15. #if !defined(_COMPRESS_INCLUDED)
  16. #define _COMPRESS_INCLUDED
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22. /*****************************************************************************/
  23. /* Definition of compression constants                                       */
  24. /*****************************************************************************/
  25. #define METHOD_STORE    0           /* store object with no compression */
  26. #define METHOD_DEFLATE  1           /* use ZIP style deflation */
  27.  
  28. #define METHOD_BEST     255         /* use best available compression method */
  29. /*****************************************************************************/
  30.  
  31.  
  32. /*****************************************************************************/
  33. /* Error constants                                                           */
  34. /*****************************************************************************/
  35. #define COMPRESS_INVALID_METHOD     ((APIRET)0xF0000000)
  36. #define COMPRESS_INVALID_LEVEL      ((APIRET)0xF0000001)
  37. #define COMPRESS_INVALID_PARAMETER  ((APIRET)0xF0000002)
  38. #define COMPRESS_INTERNAL_ERROR     ((APIRET)0xF0000003)
  39.  
  40. #define EXPAND_INVALID_PARAMETER    ((APIRET)0xFF000000)
  41. #define EXPAND_INVALID_METHOD       ((APIRET)0xFF000001)
  42. #define EXPAND_INTERNAL_ERROR       ((APIRET)0xFF000002)
  43. #define EXPAND_CRC                  ((APIRET)0xFF000003)
  44. /*****************************************************************************/
  45.  
  46. /*****************************************************************************/
  47. /* Definition of compressed data object data structure                       */
  48. /*****************************************************************************/
  49. #pragma pack(1)
  50. typedef struct _COMPRESSED_DATA {
  51.     ULONG  crc;                 /* 32 bit CRC of rest of structure + compressed data */
  52.     ULONG  ulCompressedSize;    /* compressed size of data */
  53.     ULONG  crcOriginal;         /* 32 bit CRC of the original uncompressed data */
  54.     ULONG  ulOriginalSize;      /* original uncompressed size of data */
  55.     USHORT version;             /* version of COMPRESS.DLL used to compress data */
  56.     BYTE   method;              /* compression method */
  57.     BYTE   reserved;            /* currently unused, set to 0 */
  58.     BYTE   data[1];             /* compressed data starts here */
  59.     } COMPRESSED_DATA;
  60.  
  61. typedef COMPRESSED_DATA * PCOMPRESSED_DATA;
  62. #pragma pack()
  63.  
  64. #define COMPRESSED_HEADER_SIZE  ( sizeof(COMPRESSED_DATA) - 1 )     /* 20 bytes */
  65. /*****************************************************************************/
  66.  
  67. /*****************************************************************************
  68.  * Function declarations
  69.  *****************************************************************************/
  70. extern APIRET EXPENTRY CompressObject( PBYTE pData,
  71.                                        ULONG dataSize,
  72.                                        PCOMPRESSED_DATA * ppCompressed,
  73.                                        BYTE method,
  74.                                        BYTE level );
  75. /* Description          This function compresses the designated memory object.
  76.  *
  77.  * Parameters           pData points to the data object that is to be compressed.
  78.  *
  79.  *                      dataSize contains the size in bytes of the input data object.
  80.  *
  81.  *                      ppCompressed points to the location where the pointer to
  82.  *                      the compressed data object is to be stored. The memory
  83.  *                      used to store the compressed data object is sparse allocated
  84.  *                      by the DosAllocMem function.
  85.  *
  86.  *                      method contains the compression method to be used to
  87.  *                      compress the data object. This parameter can be set to
  88.  *                      one of the following values:
  89.  *
  90.  *                          METHOD_STORE    ..... store with no compression.
  91.  *                          METHOD_DEFLATE  ..... use ZIP style deflation.
  92.  *                          METHOD_BEST     ..... use best available method.
  93.  *
  94.  *                      level contains a value from 0 - 9 indicating the compression
  95.  *                      level to be used. A value of 0 forces the data to be STORED.
  96.  *                      A value of 1 gives fast but minimal compression. A value of
  97.  *                      9 gives slow but maximal compression. Usually a compression
  98.  *                      level of 5 provides a decent speed/compression tradeoff.
  99.  *
  100.  * Return Value         A return value of 0 indicates that no error occured, otherwise
  101.  *                      CompressObject returns one of the following error codes:
  102.  *
  103.  *                      Possible OS/2 errors
  104.  *                      --------------------
  105.  *                      ERROR_NOT_ENOUGH_MEMORY
  106.  *                      ERROR_INVALID_PARAMETER
  107.  *                      ERROR_INTERRUPT
  108.  *                      ERROR_INVALID_ADDRESS
  109.  *                      ERROR_ACCESS_DENIED
  110.  *                      ERROR_LOCKED
  111.  *                      ERROR_CROSSES_OBJECT_BOUNDARY
  112.  *
  113.  *                      Compression library specific errors
  114.  *                      -----------------------------------
  115.  *                      COMPRESS_INVALID_METHOD     ..... The specified compression method
  116.  *                                                        is not supported by this version of
  117.  *                                                        the library.
  118.  *
  119.  *                      COMPRESS_INVALID_LEVEL      ..... The compression level parameter
  120.  *                                                        contained an invalid value.
  121.  *
  122.  *                      COMPRESS_INVALID_PARAMETER  ..... The pData, dataSize, or ppCompressed
  123.  *                                                        parameter contained an invalid
  124.  *                                                        value.
  125.  *
  126.  *                      COMPRESS_INTERNAL_ERROR     ..... An internal error occured in the
  127.  *                                                        compression function.
  128.  */
  129.  
  130. extern APIRET EXPENTRY ExpandObject( PCOMPRESSED_DATA pData,
  131.                                      PBYTE * ppExpanded );
  132. /* Purpose              This function decompresses the designated compressed data
  133.  *                      object.
  134.  *
  135.  * Parameters           pData points to the compressed data object to be
  136.  *                      expanded.
  137.  *
  138.  *                      ppExpanded points to the location where the pointer to the
  139.  *                      expanded data object is to be stored. The memory used to
  140.  *                      store the expanded data object is allocated by the
  141.  *                      DosAllocMem function.
  142.  *
  143.  * Return Value         A return value of 0 indicates that no error occured, otherwise
  144.  *                      ExpandObject returns one of the following error codes:
  145.  *
  146.  *                      Possible OS/2 errors
  147.  *                      --------------------
  148.  *                      ERROR_NOT_ENOUGH_MEMORY
  149.  *                      ERROR_INVALID_PARAMETER
  150.  *                      ERROR_INTERRUPT
  151.  *                      ERROR_ACCESS_DENIED
  152.  *
  153.  *                      Compression library specific errors
  154.  *                      -----------------------------------
  155.  *                      EXPAND_INVALID_PARAMETER    ..... The pData or ppExpanded parameters
  156.  *                                                        contain a pointer to an invalid
  157.  *                                                        address.
  158.  *
  159.  *                      EXPAND_INVALID_METHOD       ..... The compressed data object was
  160.  *                                                        compressed using a method not
  161.  *                                                        supported by this version of the
  162.  *                                                        library.
  163.  *
  164.  *                      EXPAND_CRC                  ..... The contents of the input compressed
  165.  *                                                        data object appear to have been
  166.  *                                                        corrupted.
  167.  *
  168.  *                      EXPAND_INTERNAL_ERROR       ..... An internal error occurred in the
  169.  *                                                        data expansion function.
  170.  */
  171.  
  172. extern USHORT EXPENTRY CompressVersion( void );
  173. /* Purpose              This function retrieves the currently installed version
  174.  *                      of the data compression library.
  175.  *
  176.  * Return Value         The major version number is stored in the high order
  177.  *                      byte. The minor version number is stored in the low
  178.  *                      order byte.
  179.  */
  180. /*****************************************************************************/
  181.  
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185.  
  186. #endif /* _COMPRESS_INCLUDED */
  187.